package com.md.mapper;

import com.md.entity.Book;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface BookMapper {
    @Select("select * from book")
    List<Book> selectAll();

    //姓名
    @Select("select * from book where bookName like '%${bookName}%'")
    List<Book> selectByName(String name);

    //id查
    @Select("select * from book where bookId = #{id}")
    Book selectById(int id);

    //id删
    @Delete("delete from book where bookId = #{id} ")
    int deleteById(int id);

    //添加
    @Insert("insert into book (bookName, bookAuthor, bookPrice, bookPic, bookPublisher) values (#{bookName}, #{bookAuthor}, #{bookPrice}, #{bookPic}, #{bookPublisher})")
    int insertStudent(Book book);

    //修改
    @Update("update book set bookName=#{bookName},bookAuthor=#{bookAuthor},bookPrice=#{bookPrice},bookPic=#{bookPic},bookPublisher=#{bookPublisher} where bookId=#{bookId}")
    int updateStudent(Book book);
}

